home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_PROPER.PRG
< prev
next >
Wrap
Text File
|
1993-05-04
|
2KB
|
61 lines
FUNCTION _Proper && Convert a String to Proper Name Format
PARAMETERS pc_string
*--------------------------------------------------------------------
* NAME
* _PROPER - Convert a string to proper name format.
*
* SYNOPSIS
* _PROPER( pc_string )
*
* DESCRIPTION
* _PROPER returns its argument with the first letter
* of each word capitalized, and all other letters in
* lower case. Note that each word must be separated
* by at least one empty space.
*
* PARAMETER
* pc_string = the string to convert
*
* EXAMPLE
*
* ? _PROPER( "smith" ) && Returns "Smith"
*
* ? _PROPER( "joe foo" ) && Is now "Joe Foo"
*
* ? _PROPER( "joe,foo" ) && Returns "Joe,foo"
*
* LIMITATIONS
* Note that _PROPER() may not give acceptable results
* on surnames such as "McDonald," "de la Vega" or
* "ffolkes."
*
* SEE ALSO:
* UPPER(), LOWER()
*
*--------------------------------------------------------------------
PRIVATE lc_result, ln_length, ln_posit
lc_result = LOWER( TRIM( m->pc_string ))
ln_posit = 2
ln_length = LEN( m->lc_result )
IF SUBSTR( m->lc_result, 1, 1 ) <> ' '
lc_result = STUFF( m->lc_result, 1, 1, ;
UPPER( SUBSTR( m->lc_result, 1, 1 ) ) )
ENDIF
DO WHILE m->ln_posit <= m->ln_length
IF SUBSTR( m->lc_result, m->ln_posit - 1, 1 ) = ' '
lc_result = STUFF( m->lc_result,;
m->ln_posit,;
1,;
UPPER( SUBSTR( m->lc_result, m->ln_posit, 1 ) ) )
ENDIF
ln_posit = m->ln_posit + 1
ENDDO
RETURN( m->lc_result )
*-- EOF: _Proper( pc_string )